import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-03
 * Time: 14:09
 */
public class Test12 {

    public static String minWindow(String s, String t) {
        int[] hash1 = new int[128];
        int[] hash2 = new int[128];
        char[] ch1 = s.toCharArray();
        char[] ch2 = t.toCharArray();
        int m = s.length();
        int kind = 0;
        for(char ch : ch2) {
            if(hash2[ch] == 0) {
                kind++;
            }
            hash2[ch]++;
        }
        int begin = -1,len = Integer.MAX_VALUE;
        for(int left = 0, right = 0,count = 0; right < m; right++) {
            char in = ch1[right];
            hash1[in]++;
            if(hash1[in] == hash2[in])  {
                count++;
            }
            while(kind == count) {
                // 更新结果
                if(right-left+1 < len) {
                    len = right-left+1;
                    begin = left;
                }
                char out = ch1[left];
                if(hash1[out] == hash2[out]) {
                    count--;
                }
                hash1[out]--;
                left++;
            }
        }
        if (begin == -1) {
            return new String();
        }
       return s.substring(begin,begin+len);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        String ret = minWindow(s,t);
        System.out.println("最小覆盖子串："+ ret);
    }
}
